<!DOCTYPE html>
<html lang="zh">
<head>
	#@header()
</head>
<body class="gray-bg">
	<div class="container-div">
		<div class="row">
			#if(permission != null && permission.get('select')!= null )
			<div class="col-sm-12 search-collapse" style="display: none" >
				<form id="role-form">
					<div class="select-list">
						<ul>
							<li>
								名称/编码：<input type="text" name="name"/>
							</li>

							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							    <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			#end

			<div class="btn-group-sm" id="toolbar" role="group">
				#if(permission != null && permission.get('add')!= null )
				<a class="btn btn-success" onclick="$.operate.add()">
	                <i class="fa fa-plus"></i> 新增
	            </a>
				#end

	        </div>
	        
	        <div class="col-sm-12 select-table table-striped">
			    <table id="bootstrap-tree-table"></table>
			</div>
		</div>
	</div>


	#@footer()
	<script type="text/javascript">
		var editFlag = true;
		var removeFlag = true;
		$(function() {
		    var options = {
		        url: "#(prj)/admin/menu/paginate",
		        createUrl: "#(prj)/admin/menu/add",
		        updateUrl: "#(prj)/admin/menu/edit/{id}",
		        removeUrl: "#(prj)/admin/menu/delete/{id}",
                code: "id",
                parentCode: "pid",
                uniqueId: "id",
		        sortName: "sort",
		        modalName: "菜单",
		        columns: [
		        {field: 'name', title: '菜单'},
		        {field: 'icon', title: '图标',
                    formatter:function (v,row,index) {
						return "<i class='"+v+"' ></i>";
                    }},
		        {field: 'link', title: '连接'},
		        {field: 'operate_ids', title: '操作权限'},
		        {field: 'pid',
					title: '级别',
                    formatter:function (v,row,index) {
						if(v == 0){
								return "<span class=\"label label-success\">目录</span>";
						}else{
						    return "<span class=\"label label-primary\">菜单</span>";
						}
                    }

				},
		        {field: 'sort', title: '排序',sortable:true},
		        {field: 'create_time', title: '创建时间', sortable: true},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	if (row.roleId != 1) {
		                    var actions = []
                        #if(permission != null && permission.get('update')!= null )
		                    actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ')
                        #end

                        #if(permission != null && permission.get('delete')!= null )
		                    actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.removeTree(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a> ')

                        #end

		                    return actions.join('');
		            	} else {
		                    return "";
		                }
		            }
		        }]
		    };
            $.treeTable.init(options);
		});


	</script>
</body>
</html>